/**
 * Created
 */
import URL from '../../config/url'
import {
  request,
  getRequestUrl
} from '../../http/http'

const actions = {
  addActivity(context, params) {
    const url = getRequestUrl({
      url: URL.api.addActivity
    })
    return request(url, params, {
      method: 'post'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  },
  getActivityById(context, params) {
    const url = getRequestUrl({
      url: URL.api.getActivityById
    })
    return request(url, params, {
      method: 'get'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  },
  updateActivityById(context, params) {
    const url = getRequestUrl({
      url: URL.api.updateActivityById
    })
    return request(url, params, {
      method: 'post'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  },
  activityDetail(context, params) {
    const url = getRequestUrl({
      url: URL.api.activityDetail
    })
    return request(url, params, {
      method: 'post'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  },
  getActivity(context, params) {
    const url = getRequestUrl({
      url: URL.api.getActivity
    })
    return request(url, params, {
      method: 'get'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  },
  deleteActivity(context, params) {
    const url = getRequestUrl({
      url: URL.api.deleteActivity
    })
    return request(url, params, {
      method: 'post'
    }).then((res) => {
      return res
    }).catch((error) => {
      console.log(error)
    })
  }
}

export default actions
